package com.ks.member.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ks.core.base.OperationContext;
import com.ks.core.util.ToolUtil;
import com.ks.member.controller.dto.MemberInfoDto;
import com.ks.member.entity.MemberInfo;
import com.ks.member.dao.MemberInfoMapper;
import com.ks.member.service.IMemberInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 用户详细信息 服务实现类
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-22
 */
@Service
public class MemberInfoServiceImpl extends ServiceImpl<MemberInfoMapper, MemberInfo> implements IMemberInfoService {
    @Resource
    private MemberInfoMapper memberInfoMapper;

    @Override
    public MemberInfoDto getMemberInfoList(OperationContext context) {
        Long userId = context.getUserId();
        MemberInfo memberInfo = memberInfoMapper.selectById(userId);
        MemberInfoDto memberInfoDto = new MemberInfoDto();
        if (ToolUtil.isNotEmpty(memberInfo)) {
            memberInfoDto.setIRealName(memberInfo.getIRealName());
            memberInfoDto.setISex(memberInfo.getISex());
            memberInfoDto.setIBirthday(memberInfo.getIBirthday());
            memberInfoDto.setIProvinceoforigin(memberInfo.getIProvinceoforigin());
            memberInfoDto.setIHometownCity(memberInfo.getIHometownCity());
            memberInfoDto.setINativePlace(memberInfo.getINativePlace());
            memberInfoDto.setINativePlaceAddress(memberInfo.getINativePlaceAddress());
            memberInfoDto.setIWechatNumber(memberInfo.getIWechatNumber());
            memberInfoDto.setIQQNumber(memberInfo.getIQQNumber());
            memberInfoDto.setIOccupation(memberInfo.getIOccupation());
        }
        return memberInfoDto;
    }
}
